package com.hjj.java.se.objectRep;

import java.io.*;

public class Test {
    public static void main(String[] args) throws Exception{
        File file = new File("ObjectRepTest.txt");
        OutputStream outputStream = new FileOutputStream(file);
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
        SerializableObject so1 = new SerializableObject("str0", "str1");
        System.out.println(so1);
        objectOutputStream.writeObject(so1);
        objectOutputStream.close();

        InputStream inputStream = new FileInputStream(file);
        ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
        SerializableObject serializableObject = (SerializableObject) objectInputStream.readObject();
        System.out.println("str0: " + serializableObject.getStr0());
        System.out.println("str1: " + serializableObject.getStr1());
        System.out.println("str2: " + serializableObject.getStr2());
    }
}
